package com.zcb.qingshoudan.activity;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.zcb.qingshoudan.R;

public class GatheringActivity extends Activity implements View.OnClickListener{
    //title main
    private TextView titleTV;
    private LinearLayout titleLinearLayout;

    private Button gatheringAtonce;
    private EditText gatheringMoneyEd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_gathering);
        Intent intent=getIntent();
        String shangjia=intent.getStringExtra("shangjia");
        initView(shangjia);
    }


    private void initView(String shangjia){
        //title main
        titleLinearLayout= (LinearLayout) findViewById(R.id.title_lin_back);
        titleTV= (TextView) findViewById(R.id.title_text);
        gatheringAtonce= (Button) findViewById(R.id.gathering_atonce);
        gatheringAtonce.setOnClickListener(this);
        gatheringMoneyEd= (EditText) findViewById(R.id.gathering_money_ed);

        titleLinearLayout.setOnClickListener(this);
        switch (shangjia){
            case "wx":
                weixin();
                break;
            case "zfb":
                zhifubao();
                break;
        }

    }


    private void weixin(){
        titleTV.setText("微信收银");
        titleLinearLayout.setVisibility(View.VISIBLE);
    }

    private void zhifubao(){
        titleTV.setText("支付宝收银");
        titleLinearLayout.setVisibility(View.VISIBLE);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.title_lin_back:
                finish();
            break;
            case R.id.gathering_atonce:
                showQRCode();
                break;
        }
    }


    private void showQRCode(){
        String code=gatheringMoneyEd.getText().toString();
        if (code.equals("")){
            Toast.makeText(this,"输入不能为空",Toast.LENGTH_SHORT).show();
        }else {
        Intent intent=new Intent(this,GatheringQRCodeActivity.class);
        intent.putExtra("QRCodeInfo",code);
        startActivity(intent);
        }

    }
}
